JBoss Community Archive (Read Only)

Infinispan 5.0

Writing custom commands in Infinispan

Infinispan makes use of a command/visitor pattern to implement the various top-level methods you see on the public-facing API.  This is explained in further detail in the Architectural Overview on the Infinispan public wiki.  However, these commands - and their corresponding visitors - are hard-coded as a part of Infinispan's core module, making it impossible for module authors to extend and enhance Infinispan to create new, arbitrary commands and visitors.  

However, since Infinispan 5.0, this capability has now been added.  As a module author (such as infinispan-tree, infinispan-query, etc.) you can now define your own commands. You do so by:

  1. Creating an infinispan-module.properties file and ensuring that this is packaged in the root of your jar file.

  2. Implementing ModuleCommandFactory and ModuleCommandInitializer from infinispan-core

  3. Specifing the fully-qualified class names of your implementations in infinispan-module.properties

  4. Implement your custom commands and visitors for these commands

Here is an example of an infinispan-modules.properties file, configured accordingly:Code Snippet error: Unable to retrieve the URL: https://github.com/infinispan/infinispan-sample-module/raw/master/src/main/resources/infinispan-module.properties status code: 404.

For a full, working example of a sample module that makes use of custom commands and visitors, check out https://github.com/infinispan/infinispan-sample-module.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-11 09:09:13 UTC, last content change 2011-07-11 11:12:47 UTC.